event detect in loop