moved listener and the variables to state.create