Added when conditions in main