Would these be clearer if the onsuccess and onerror functions were extracted and placed into "private" functions on the module?