refactor some code

Signed-off-by: summerdaway <summerdaway@gmail.com>