added some logic to fw_hookfn()