removing debug code, added check for original file