Moving around some code for clarity and reuse