adjusted some logic