added feature detection on console code

added if(console) to code where it is used.