improve border generation