fixing a mistaken if check