add cealign to dock-thorp and organize code into functions