Generate hasKey() helper method