Changed the code completely to a different calculation