isValid checking added