move functions out of functions