Refactored State.Process

Use Aggregate function to improve the logic.