Bugfix: correctly handle ranges