Updated to handle multiple events