add update method, some refactoring, updating