Added validation code
Added validation function