slight improvement on space requirement from theta(n^4) to theta(n^2) by using one board the whole way through