more work on the ctp. still not completely correct