Avoid using long switch statement.

Signed-off-by: crynobone <crynobone@gmail.com>