change to case/when, added mdulus and exponent