create state event object in separate function