fixed bug - things seem ok - need to put in near boundary calculations