Rewrite read code