Corrected last_dim_value bug