move functions to top