implemented the read function