implementing loop to get values