matrix generation bug fixed