extract functions to separate file