Add checking for duplicate keys

Signed-off-by: Ian Macalinao <me@ian.pw>