<s>[INST] I'm trying to code a game and I want to make sure I do it efficiently. Here is my game loop, but I'm having trouble with the collision detection. The game loop is built with Python and using Pygame for the game development library.

```python
import pygame
import sys
import random

# Game Variables
screen_width = 640
screen_height = 480
screen = pygame.display.set_mode((screen_width, screen_height))

class Player(pygame.sprite.Sprite):
    def __init__(self):
        super().__init__()
        self.image = pygame.Surface((50, 50))
        self.image.fill((255, 0, 0))
        self.rect = self.image.get_rect()
        self.rect.center = (screen_width / 2, screen_height / 2)
        self.speed = 5

    def update(self):
        keys = pygame.key.get_pressed()
        if keys[pygame.K_UP]:
            self.rect.y -= self.speed
        if keys[pygame.K_DOWN]:
            self.rect.y += self.speed
        if keys[pygame.K_LEFT]:
            self.rect.x -= self.speed
        if keys[pygame.K_RIGHT]:
            self.rect.x += self.speed

class Enemy(pygame.sprite.Sprite):
    def __init__(self):
        super().__init__()
        self.image = pygame.Surface((50, 50))
        self.image.fill((0, 0, 255))
        self.rect = self.image.get_rect()
        self.rect.center = (random.randint(0, screen_width), random.randint(0, screen_height))
        self.speed = random.randint(1, 3)

    def update(self):
        if self.rect.x < 0 or self.rect.x > screen_width:
            self.speed = -self.speed
        self.rect.x += self.speed

# Game Loop
def game_loop():
    clock = pygame.time.Clock()
    player = Player()
    enemy = Enemy()
    all_sprites = pygame.sprite.Group()
    all_sprites.add(player)
    all_sprites.add(enemy)

    running = True
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

        all_sprites.update()

        # Collision Detection
        if player.rect.colliderect(enemy.rect):
            print("Collision detected")

        screen.fill((0, 0, 0))
        all_sprites.draw(screen)
        pygame.display.flip()

        clock.tick(60)

    pygame.quit()
    sys.exit()

game_loop()
```

When I run this code, the collision detection is working, but I was wondering if there's a way to improve it?[/INST]