There's enough duplication here to pull it out of the switch statement and handle it afterwards.