move clean up to end