added common extract function