Move functions to the top