added clear button, fixed bugs