Extract code into functions.