error checking and better resume capability