Made connection to mongo generic, fixed bug