Implementation to pass tests, needs refactoring -mbb