only use one grid traversal to calculate all errors
clang-format