Minor refactoring

I noticed this minor code duplication when reading the code, and wanted to give it a try.
Feel free to reject this pull request if it doesn't fit your design.