Take great pains to do (something)

To make a great effort to do something.

The painters took great pains not to spill any paint on the carpet.