Refactored code so that buttons group actions cannot be performed without having a group selected