refactor match saving with ajax functionality