Fixed a bug where the array tried to access a non-existent index