inspired by https://github.com/michelp/pgfsm
According to this post, we should prefer JOIN over CASE.
JOIN
CASE