Refactored for more legible code