modified the compare event function.