bug in matrix creation