bugfix in writing values