More accurate but slower
Updated webapp script