This is a lot of copy-paste code.