Resolved the infinite loops