fix reader function