optimize intermediate