got resistance and capacitance algorithm working