fix busy loop in read method