refactored the statemachine's execute method. #13