Refactored to implement sql queries and button functionality.
	# Please enter the commit message for your changes. Lines starting