Handle ok, apply and cancel events
Refactoring, implement valid method