Functionallity working now with for loop