diagnostic argument added. fixed current_length reset