add gen algorithm