fixed deallocate bug