rewrite of pool version with redundant classes removed