code restructure to be more modular/reusable