added missing nil check