add pins, and simplify controller code