improved connection handling using mongoose