updated Error catching