changed mode to mode* array.