Update debug function to be generic