add code for debug mode