using sandbox foreach; changed function name