added a function to compute color