write_to_ram refine