Move commit to the end of script to avoid problem with offset