implemented part of the ajax functionality