remove trailing comma and semicolon