fix variable write error