Modification on the Bresenham algorithm to fix some mistakes