better extraction script