fix bug in cleanup