Avoid dangling elements.
A dangling element is a verbal phrase (participle, gerund*, or infinitive) used without an explicit subject. Because this phrase has no stated subject to which it can refer, it unintentionally refers to an inappropriate subject in the main clause and confuses your reader (as I am probably confusing you).
Two ways to correct a dangling element are:
1. Use the noun or pronoun that the dangling element refers to as the subject of the main clause.
2. Turn the dangling element into a clause with its own subject.
In other words, a dangling element should refer or “stick to” the nearest subject, and that subject in turn should be the subject of the dangling element. Don't worry — it makes more sense in an example or two.
a) Sitting in Café Opus, my car got a parking ticket.
The dangling participle in this sentence is sitting in Café Opus; its subject (presumably I) is not stated. The nearest subject, my car, was probably not sitting in Café Opus.
Possible correction: While I was sitting in Café Opus, my car got a parking ticket.
b) In driving to the Rok, my ID was lost.
Presumably, your ID didn’t make a wrong turn while it was driving to the Rok; therefore, the dangling gerund driving should not refer to my ID.
Better: While driving to the Rok, I lost my ID.
c) To avoid stress, all assignments must be started ahead of time.
Dangling infinitive to avoid.
Better: To avoid stress, you should start your assignments ahead of time.
See also Misplaced modifier (“mp”) in this handbook and The Fifth Deadly Sin: Misplaced and Dangling Modifiers.
* A gerund is the form of a verb that ends in _ing and functions as a noun (see examples).