error checking & some comments