fixed check for existing keys
Merge pull request #1 from mthie/master

Fix for the key check