Updated validation code