fix for nested matrix