refactor some methods into utilities