move code to util