Added first window logic
Improved render code'