fixing available buffer reading