added method buildGenMatrix