extraction subroutine w/ counter