finished math backend abstraction