add error checking to read