Fixed logical issue