Added all code from Mike's most recent version except code from toggleButton method