Simplifying code

Kudos to Lucas van Lierop for the refactoring