add utils and refactor