Refactoring bob in scala