changed error message and flash type