remove haarcode from onOpen and onClose handlers