adding loop mode control