added some logic to main