Optimize codes

Signed-off-by: Jesse Hwong <huangnonghuan@gmail.com>