Rewrite read function