Added a bit of validation logic.