moved functions to top