reorganize structure of code