function to read data