fixing indexing bug; refactoring color generation