move functions to routes