Added lambda function to check bordering indices