Fixed bug where calculations weren't giving the correct results