refactored functions out into separate file