Thanks for the help, it was a stupid problem of me not editing using the correct variable when in the array, so the array index was negative.