Code refactoring

Signed-off-by: Yinan Li <liyinan926@gmail.com>