OK button enabled if equation valid, refactoring