added quadrant checking and final calculation checks