moved discard detail changes out of function to prevent multiple calls