Excluding deployer from transfer tax

I am trying to add a 9% tax to every transfer except those done by the deployer (see bolded code for the exclusion logic). However, after playing around with some swaps on pancakeswap testnet I have found that transfers called by the deployer are still taxed. What's wrong with the if statement?

:1234: Code to reproduce

pragma solidity ^0.8.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/f1e92dd184a599f39ce9cc4ec8a5e4a94416f3a2/contracts/utils/math/SafeMath.sol";

contract token is ERC20 {
    using SafeMath for uint256;
    uint taxPercentage = 9;
    address public deployer;

    constructor(uint256 initialSupply) public ERC20("token", "token") {
        _mint(msg.sender, initialSupply);
        deployer = msg.sender;

    function transfer(address recipient, uint256 amount) public override returns (bool) {
        **if (msg.sender == deployer) {**
**             _transfer(_msgSender(), recipient, amount);**
**        } else {**
            uint taxAmount = amount.mul(taxPercentage) / 100;
            _transfer(_msgSender(), deployer, taxAmount);
            _transfer(_msgSender(), recipient, amount.sub(taxAmount));
        return true;

:computer: Environment


You are overriding the transfer function. In most cases, like putting liquidity onto a DEX, the function being used is transferFrom.

To make sure your logic applies to all transfers, you should override the internal _transfer function, and not the public one. I recently discussed how to possibly do it in this message