fix bug with cleanup