Moved some code into functions