Refactoring
Refactoring, added writing to history