improved debug mode