Fixed more logic errors