Function ncols improved