Optimized code and added color adaption