Add check for nil player inventory