Illegal index if no output - fixed