separate out some functions into a util file