add dimension detection by examining the first tuple