refactored some functions into a new file