optimize board drawing code