A participial phrase at the beginning of a sentence must refer to the grammatical subject.
This is one of my favorite rules. Well. Not really. But I think every high school student should be required to read (and memorize) William Strunk, Jr.’s Elements of Style. I don’t know how you could have possibly made it through high school and college without ever buying this book. If you did, though, don’t worry. The folks at bartleby.com have made the full text available on line. Don’t write anything — ever — without checking Strunk’s rules first. Of course… that’s just my opinion. <grin>