Refactor out into a helper method