Created last.sample function