The core principle of writing good functions is separate intention from implementation. The block of the code should be extracted into the function if you have to spend mental effort while reading it to understand what it does. With the name of resulting function giving a clear answer to the "what" question.
This is another way of Respecting level of abstraction
At a first glance this seems like it contradicts functions should be small. But that's not really the case - when you start following the underlying principle of separate intention from implementation - you'll notice your functions getting smaller. Usually ending up just a few lines long. So while the size in itself is not the point - keeping functions small can serve as a proxy/heuristic for the underlying principle.