In the following sentence, is there an error ? If so, what is it and what is the right form ?
I thanked him for the great trouble he had taken
in organising that function.
It looks grammatical. However, some, not all, might consider "that" to be too far away from its referent.
. . . in organizing the function.