fixed the horrible loop