maybe it's better to do this inside the onsuccess handler, right?