Fix some bugs
Add loop prog