insert debugging for each function