This block seems like a fair amount of code duplication.