Bugfix: prevent potential infinite loop