fixed create_source function and corrected some debugging output