Refactoring the method to transform string to url key