refactored by creating preparePlayersArray function