support for handling advanced cases of loops