use toId() instead of .toLowerCase.replace(/[^a-zA-Z0-9]/g,"")

and minor fixes