Updated close tiles code to return variable distance of tiles