fixed hardcoded sample index bug