Better switch implementation