optimize unbind function