updates in isValid function