debugged memrory write problem