Use Math.floor() to avoid rounding issues
Rewrite calculateOffsetFromTrigger to be DRYer