Attaching a patch to fix the issue. Please review.