refine reader code