rewrote the userVisibilityCode so it can be re used