This function could also be extracted into its own file.