updated next button condition