wonderful code duplication to make it compatible with old GCC