edited read function