fixed bug in color representation and cleaned code