Code refactoring in Board.js