Updated to use debug instead of console.log