optimize a logic.