Applying state transition pattern