avoid using the SYSUSERS table, sys.database_principals should be used instead. Incidentally, you make no provision for any certificates and their mapped users that may be in use
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉