Correct grid algorithm
work in progress