added mongodb integration and flash messages