added c version of maha calc for speed