added is_valid check function to constraint variables