added button and some refactoring