Fixing 'for' statement