Remove nested loop used in drawing buffer