cleaned up code and added dialog to reset button