error handing corrected