reorganized functions and added reset button