added states to the read() function