changed loop boundaries, no memory errors yet
ex4 serial version seems to be working again