refactor some helpers