extract in a function