fix error on local variable 'handler' referenced before assigment.