add more loop methods; fix some bugs