move functions to controllers