Move functions to Model module