When the FSM returns a loop error, it means that somehow your int test doesn’t work, and it goes through the roof (or cellar in your case). Check the exact order and especially check where in the action list the events are sent. Everyone has this (self made) bug eventually, where you scratch your head why it doesn’t work, only to find out that an action is never executed, because another action above it redirects to a next state.
Next, check global events. They can also jumble up the routine in a single FSM, e.g. when a transition is called Foo, and you forgot you used it, and you send event Foo in a broad way (not specifying the target FSM) — that’s why global events should always stand out (mine are ALLCAPS for example).
Next, check the sequence. Did you swap the formula around (b minus a, instead of a minus b)? Does a variable need to be reset with each loop, and you forgot that? When the actions are in one state, and must be executed in exact sequence, did you set the state to sequence (right click on state)? Otherwise, the actions merely start in order, but can finish at different times (and out of order).
If it is a simple FSM, and you cannot figure out what goes wrong, but you can make a new one and this somehow works; maybe it’s better to just throw the broken one away, and move on with the working version. It’s good trying to find out what exactly went wrong, up to a point.