Implement foreach macro