modif from Hauke Rehr on extract output