Improve box() algorthims in range.js