refactored boardGen code