Moving functions

moved helper functions to separate file for readability