potential index-off bug-fix