added debug switch