Refactor out swap