add mongoose error handling and automatic reconnect