Added logic for parsing events