added flash alerts and polished some code in controllers/views