moved helper functions and associated to header file