added
aded color diff
added proper casts on malloc