clean up code to read data