refactoring and adding better messaging/validation.