finished refactoring, implement exit button and check