Added index protection when accessing the player array.