Added foreach function