Successfully implemented contiguity formula

Formula appears to affect performance