Fixes according to the comments in the 1st commit; function same_quadrant was added