Enhance border collision resolving logic