add checkpoint is working properly but is mess in code need to clean up