fix error using defer/panic