fix for infinite loop