Extracting bug fix into it's own ticket #3785

This code is part of an unrelated bug fix. 
Fixing it in it's own ticket.