CRM-12726 : applied patch and did some modifications
CRM-12726 : code improvement
Merge pull request #915 from pratik-joshi/CRM-12726-fix

CRM-12726 : applied patch and did some modifications