Small refactor of helper function.