fix tyop, add loop structure