updated logic