removed code duplication in displaying toasts.