fixing "off by one"-bug