Fix potential nil error