What is the electrical function of a capacitor when it is charging