Refactor cs_completer to reduce complexity