add logfunction, refine cmd