small logic changes