refactored status clean up into a method and moved all cleanup together