fixing off by one issue