state machine
refactor events / state machine