call trim() method on string for validation and removed useless anonymous function wrappers