add utils, refactoring some code