added validations and whitespace trimming