fixed error that causes -1 to be treated as infinity