created  separate function to calculate entropy