moved to read function