fixing off by one ! error