fixed issue with cleanup code