fix the starting index issue