got foreach working, added endpoint mode