refactore functions to show it as function model