# Whats a good way to implement multiple rates into crowdsale?

Hi guys,
i am trying to deploy an allowance crowdsale contract, I have it working just fine. But I have multiple rates depending on the amount of ETH that is sent to the contract. I have deployed 3 different contracts for each rate but that seems super inefficient.

My rates are:
If weiAmount < 1310**18 rate is 66666
If weiAmount > 13
1018 && < 25*1018 rate is 100000
If weiAmount => 26*10**18 rate is 400000

I know I need to override this function:

``````/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
return weiAmount.mul(_rate);
}
``````

Now logically I think that setting rate at 400000 once and then dividing it by 4 or 6 depending on wieAmount is the best approach.

Qustion #1. is there a better way?
Question #2. How can I write this in Solidity without breaking any furniture?

#### Code to reproduce

This is how I am thinking of doing it:

``````/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
super._getTokenAmount(uint256 weiAmount);
if (weiAmount < 13*10**18) rate = rate;  else if(weiAmount > 13*10**18 && weiAmount < 25*10**18) rate = rate.div(4); else(rate = rate.div(6));

return weiAmount.mul(_rate);
}
``````

Any insight on how to execute this without a million errors would be greatly appreciated.

Truffle
Solidity v0.5
VScode