This should be a separate function.