Move functions in controller