Refactor, add entropy calculation