implemented bresenham algorithm