Tried to make a loop but failed