fix loc boundary handling