Move the PR 2821 from master to staging

Based on comment from bakual in PR 2822, I have move this PR from master to staging and also included the enhancement frm mbabker