optimize completions.py