Improve render code