abstracted out corner and border logic