playing with finite-state-machines in Scala