completed task, started refactoring and writing tests