ported to mongo, compiles but errors while running