Use more reliable method to determine the row to insert before, and fix
whenDone typo