the end() iterator is saved before the loop, else it is called too many times (returning identical value everytime)