correct small logic errors