fixed bug with read termination