improved buffer by optimizing code to draw tiles