Refactored a little bit according to the rubocop gods