rewrite some instances of do.call()