fixed minor issue on indexes
fixed negative indexes