The connections between the parts of a sentence can go wrong if a phrase is not near what you intended it to modify. (The same principle applies to limiting modifiers like almost, merely, nearly, only, and simply.)
When sneaking illicit treats, we notice that the residents look guilty.
Here we, the staff, seem to be sneaking those illicit treats:
This mistake goes by the name of dangling modifier or dangler. To correct a dangling modifier, you usually have two options. First, you can revise the main clause so that the word or phrase comes just before the word it modifies:
Second, you can revise the modifier so that it includes a subject and verb of its own.
Writers often make a subtler version of that mistake by trying to connect a modifier to a possessive noun, like Mary’s in this example: