refactoring some functions into separate files