cleaned some logic