Added text color determination functionality