add stage for iterating over phases and states. todo: 1. test case for stages. 2. test case for coordinator.