refactor the print board algorithm