moved helper functions

moved helper functions to this file