removed type hint for the flatten exception