refactored events and states variables, handle events with array value for from state