Fixed function to determine the columns of a result