removed extra $total_chars variable