made code a lot more modular