fixed bug: wrong variable being referenced