combined some logic