checks whether button is defined instead of checking length