added foreach function