moved helper functions to util