adding flash message
minor refactor