added null checking and fixed initial board setting