refactor support functions