added some comment and error printf