refactor hmac