Fix for CARBON-14767
Refactored the fix
Merge branch 'isuruwan-master'