working on colour algorithm