Moved some code to make the read button work properly.