updated sql to match last change for boxes to pages