remimplement multi-stage if as case block