refactored user team leave and team delete functionality