added read_to_memory api function