Move helper functions to util