State machine-like pattern for sequential processes