Fixed undefined check of variable