Rewrite read_data to remove complexity