Refactored code to better reflect OO design and the LSP principle