Migrating math into service