Move function declarations to top