Refactoring, added OnShow and OnHide