fixed bug in dispose()