use boost function to rewrite this.