Refactor add_participants() js function for better readability