Refactored innner class for math functions