some reorganization
add some pdf logic