fast ERI computation, but ugly