rewrote rate-limit handling