Remove unused code and simplify the main function.

Signed-off-by: cctsao1008 <chiacheng.tsao@gmail.com>