button functionality and counter