write to the correct address