fix a bug in cleanup