Refactor utils