Optimized logic for screen writing