Refactor summary controller

please verify for correctness.