refactor and use same for/cond-clause for untyped and typed