fix variable handling