Well done Shruti! Your final function can be a suitable one for Wolfram Function Repository. What do you think about it? Then every user will be able to use your function in any Wolfram Language computation.
That sounds great! Thank you for the opportunity!