Implement Scala version of mongo processing.