Refactored so that the business logic does some basic input validation