added some logic