Added debug function as option