Should move this into a separate function.