Better performance with tf.function