updated logic to remove unnecessary check