GUI-1309
applied fix from elsewhere to this code
merged upstream develop