some restructuring and ideas for modularity