Code refactoring based on code review

Special thanks to @lcpriest for performing the code review! Cheers :beers: