refactor some of utils