changing math api to be more robust

1 job for master in 2 minutes and 21 seconds (queued for 3 seconds)