moved some code to functions