serial implementation of dynamic for: