refactor functions to seperate files