Improved apply functionality of State Machine