Working version of extract
Refactoring of xf:at and xf:extract