Fixed logical bug