fixing bugs in read