Updated code to validate