Fix loop direction