more robust gamma function