refactor and improve generateDesign code