code cleanup and modularity