fixed error caused by variable not being set