'output' must be returned after this 'end'. (in last of this else-block).