adding check of undefined variable