Since you're editing this line anyway, could you get rid of the !!~ idiom please?  I think it means !== -1, but it is pretty much opaque to me