color algorithm debugged null ptr