Refactored HTML, added some calculation logic