refactor some utility methods