changed the pixel loop to eliminate some additions and multiplications