fix incorrect logic