fixed more logic errors