faster genchain

removed a lot of ifs.