Rewriting using Akka FSM