attempted a rewrite per @technicalpickles suggestions