removed alerts for error messages and added a flash for errors