move function declarations to top level