refactoring + added history.