cleaning up for-loops