Fixing undefined variable notice