adjust indices in callback