implemented event listening logic and event deserialization