fixing bug to do with bookend indicies due to a reused variable name