changing the reordering and insertion of authentication to be a bit more efficient