more robust get-users function