remove debug printfs; mark function as internal