I really do not understand what you are trying to achieve. Could you post the entire forward function and any code that might “reuse the stored detach” as you put it?
For info, there is a button for formatting code. It looks a little like this [ </> ].