refactored read_data()