added flash message validation