worked on read function