edit function and checkcode