better colouring algorithm