properly check for null variable