further improvements to the ajax function - now a variable that is called on change to core field or pi field