bugfix off by one error