changed for-loops