I have decided that instead of asking this question, I should have adjusted my code to remove the need for it entirely. Some comments kindly alluded to this which helped me arrive at this conclusion (thank you). My function is better for it.