fixing logic - changes were not being written