calculating on bondaries