changed exception handling  to show an alert