created the same logic with both learned loops, also called them inside a profilling method to check that while is quicker