Added check for null variable