fixed bug with cleanup