fixed rgb checking logic