added debug flag for console.log