more accurate check on calls to read and write