Rewrite users

The code was somewhat hard to read
There was a bug in there as well, I suppose this fixed it