Fixing calculation
Changing API used in the script.