simpler to wrap both lines in an if:

    if (cx > 0) {
      ..
    }