move the total++ to the right place