Updated fix for null variable error