Changed indentation and moved console.log into debug checks