Refactored the db connect code to instantiate with uri