improved event edge detection algo