Implements user and event state distribution

`end` at 359, 6 is not aligned with `states.each do |key, value|` at 353, 4