moved all color calculations to one function
removed unneeded functions
added option for compiling a whole loop