Wrote entropy function