circuit direction problem solved, but needs code cleanup.