refactor according to @ritch's notes

Signed-off-by: Clark Wang <clark.wangs@gmail.com>