Move this to a separate function.