added some additional logic