refactor so you can pass in a block