added own implementation of foreach