updated validity check