alternative fix for #625 that avoids code duplication