fixed leaked memory when updating variable values