added method to check if a key exists