Seperated color detection code from picture fragment code and refactored