working for every mode except 0 and > 1 and < 18