Added last.sample function