more validation and handling of special characters

Change-Id: Ibf2c3832a7eb42626fd01162fcf3df85a5c6cbf5