added a function: update variable current