More efficient implementation of cycle detection based on slow and fast moving cursors