properly handle debug