added clear button and fixed functionality