reimplemented detection of natural loops