refactoring, updates from reading scala book