*move functions to mvc pattern