refactor to take in a list of coordinates