Fixed problem with color sorting routine