Hi Prabuganesh,
I would recommend you to go through the functional specification for this custom function to understand its functionality and why it was built.
That will help you to understand why you are encountering this error.
I believe this scenario may not have been taken into consideration while designing this custom function.
Thanks and regards,
Vivek Barnwal