added gamma function