fix small bug related to the clearAtEnd option in the sample