moved some code to utils