fixes recursive endless loop

This change fixes the problem with recursive endless loop