Fix handling of multiple matches

Choose the first match when there are multiple matches
Merge pull request #7 from jpnurmi/head

Fix handling of multiple matches