fixed error of comparing pointer to less than 0