refactored functions to seperate files