added mongo null error handling