Extracting logic separate from the API file.