Refactor slug functions