Trying to make the code a little more modular. Still work in progress