added debug statements using debug()