add check code to ensure proceed only if succeed