refactorings per @alexcrichton's suggestions