almost finish optimization. cannot compile