Fixed incorrect logic