Minor refactoring, trying to weasel the ajax function somewhere else