Fixed issues with calculations