fixed global cursor bug in insert_pet function