added debugging logic