Note that this is syntactically ambiguous – a lovely feature of English. Try writing a sentence that isn't.