removed global leak by adding missing var to one of rval occurences