improved robustness of function for drawing global borders