taken from https://github.com/AIGMix/AIGPY
