did refactoring
preparing samples with finite state machine