Refactor enableButton function