cleaned up and centralised event management