add terrain border logic