reorganizing for simplicity and modularity