Changed debug code to real code