An implantable stimulator for stimulating muscles or nerves, including, an array of electrodes for electrically stimulating muscles or nerves, a controller for controlling the activity of the electrodes, and wherein the controller is adapted to dynamically select the electrodes that are used to participate in stimulating the muscles or nerves.