reorganizing
rearranged much code