added auto-debugging code