some logic changes