Attaching a patch to fix this issue.
Please review.
Thanks!