create function handleColor to handle the node color