split out some functions into utils.R file