Made the loops much simpler again