auto setup pieces and fix bug in buttons