Make sure modifiers describe something that is in the sentence.
Walking outside, the stars were beautiful.
Never having taken math before, the test was difficult.
Who was walking outside? It sounds like the stars were walking. Who has never taken math before? Here are better versions of those sentences.
Walking outside, we looked at the beautiful stars.
Never having taken math before, he found the test difficult.