change calculation to use new if/then control. Try to make it a little less FUGLY.