Fixed console.log undef protection