created the function of refresh and improves the ajax queries