setting up onsuccess functions to git rid of race