refactory event processor logic.