fixed printf statements to reflect where error occurs