made slug generating code more robust