factor stack out into separate package