Added a bit of validation and fixed a typo.