reform brightness computation to make it more readable