changed index controller and partial logic to account for N+1