using guard patterns rather than trees of cases