updated the for-loop with Gottox' proposal