Fix the infinite console.log loop issue