refactor functions file