Use a register map instead of a switch statement