render loop works but incredibly slowly