Fix backend index out of range bug