Refactored a silly bit of code