updating the logic