Refactoring for fun and better input handling