Code for COWTAP