single while loop works