off by one error in ~ at the end checking