functionality for button works correctly now.