moved some functions to utils