         if !enemiesLoaded {
             enemiesLoaded = true
             
-            // Get data from the API, parse it, and add pins to the map
-            let apiURL = "http://woodsman.jessemillar.com:33333/database/" + String(location!.coordinate.latitude) + "/" + String(location!.coordinate.longitude) + "/" + String(enemyRadius)
-            print(apiURL)
-            let url = NSURL(string: apiURL)
-            
-            let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in
-                do {
-                    let json = try NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments)
-                    
-                    if let coordinates = json as? [[String: AnyObject]] {
-                        for cursor in coordinates {
-                            let newEnemy : Enemy = Enemy()
-                            
-                            if let latitude = cursor["latitude"] as? String {
-                                newEnemy.latitude = Double(latitude)!
-                            }
-                            
-                            if let longitude = cursor["longitude"] as? String {
-                                newEnemy.longitude = Double(longitude)!
-                            }
-                            
-                            self.enemies.append(newEnemy)
-                        }
-                    }
-                } catch {
-                    print("error serializing JSON: \(error)")
-                }
-                
-                for enemy in self.enemies {
-                    let pin = EnemyPin(coordinate: CLLocationCoordinate2D(latitude: enemy.latitude, longitude: enemy.longitude))
-                    self.mapView.addAnnotation(pin)
-                }
-            }
-            
-            task.resume()
+            getEnemies()
         }
     }
     

                let cone = 0.1

                if abs(data!.acceleration.x) > (0.9 - cone) && abs(data!.acceleration.x) < (0.9 + cone){
//                    print("Ready")
                }
            }
        } else {

        
        return number*PI/180
    }
    
    func getEnemies() {
        let latitude = "\(userLatitude)"
        let longitude = "\(userLongitude)"
        let radius = "\(enemyRadius)"
        
        var apiURL = baseURL
            apiURL += "/database/"
            apiURL += latitude + "/"
            apiURL += longitude + "/" + radius
        print(apiURL)
        let url = NSURL(string: apiURL)
        
        let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in
            do {
                let json = try NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments)
                
                if let coordinates = json as? [[String: AnyObject]] {
                    for cursor in coordinates {
                        let newEnemy : Enemy = Enemy()
                        
                        if let latitude = cursor["latitude"] as? String {
                            newEnemy.latitude = Double(latitude)!
                        }
                        
                        if let longitude = cursor["longitude"] as? String {
                            newEnemy.longitude = Double(longitude)!
                        }
                        
                        self.enemies.append(newEnemy)
                    }
                }
            } catch {
                print("error serializing JSON: \(error)")
            }
            
            for enemy in self.enemies {
                let pin = EnemyPin(coordinate: CLLocationCoordinate2D(latitude: enemy.latitude, longitude: enemy.longitude))
                self.mapView.addAnnotation(pin)
            }
        }
        
        task.resume()
    }
    
    func shootEnemy() {
        let enemyLatitude = "\(enemyAimedAtLatitude)"
        let enemyLongitude = "\(enemyAimedAtLongitude)"
        
        let endpoint: String = baseURL + "/" + enemyLatitude + "/" + enemyLongitude
        let endpointRequest = NSMutableURLRequest(URL: NSURL(string: endpoint)!)
        endpointRequest.HTTPMethod = "DELETE"
        
        let config = NSURLSessionConfiguration.defaultSessionConfiguration()
        let session = NSURLSession(configuration: config)
        
        let task = session.dataTaskWithRequest(endpointRequest, completionHandler: {
            (data, response, error) in
            guard let _ = data else {
                print("Error shooting enemy")
                return
            }
            
            self.mapView.removeAnnotations(self.mapView.annotations) // Remove all annotations from the map
        })
        
        task.resume()
    }
}
