ported fix for issue 243