reorganize code
finished feature 214