nit: use Math.floor, we don't need to be clever.