Tried to solve dithering exercise