change extract implementation to avoid weird GCC bug