Changed some things to the calculation algorithm