Rearrange to make it more managable

Signed-off-by: Huy Bui <anhhuybk@gmail.com>