added pins, cleaned up some code