adds logic to buttons