fixing mongodb connection handler