Fixed a bug in saving sample