fixing variable ref. to prevent crashing