Small refactor

Just made it a little more readable and cut down on duplication slightly.