This section of code has a lot of duplication from the normal createpills button.