Fixed potential index out of range panic