put events and middleware into the utils file