Port of newer button logic