Added mongodb as a database.Refactored code.fixed bugs