implemented some math functions